﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RM2012Service.DataService;
using System.Data;
using System.Data.SqlClient;

namespace RM2012Service.DataAccess
{
    public class AreaDAO
    {
        DBConnection db;

        public AreaDAO()
        {
            db = new DBConnection();
        }

        public DataTable GetAllArea()
        {
            return db.ExecuteDataTable("GetAllArea", null);
        }

        public DataTable GetAreaById(string areaId)
        {
            SqlParameter param = new SqlParameter("@AreaId", SqlDbType.VarChar, 6);
            param.Value = areaId;
            return db.ExecuteDataTable("GetAreaById", param);
        }

        public object GetAreaIdByName(string areaName)
        {
            SqlParameter param = new SqlParameter("@AreaName", SqlDbType.NVarChar, 100);
            param.Value = areaName;
            return db.ExecuteScalar("GetAreaIdByName", param);
        }
    }
}
